﻿Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Seuss.EnterpriseLibrary.DataAccess
Imports Seuss.EnterpriseLibrary.BusinessLogic
Imports System.Web
Imports System.Data

Partial Class Consulta_PA_InfoAcad_Plan
    Inherits System.Web.UI.Page
    Dim cPerCodigo As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Expires = -1
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("cache-control", "private")
        Response.CacheControl = "no-cache"
        cPerCodigo = Request.QueryString("cPerCodigo")

        If Not Page.IsPostBack Then
            lblcPercodigo.Text = cPerCodigo
            Call CargarCurriculas()
            Using Seguridad As New BLL_Administracion
                Seguridad.Set_Transaccion_Insert(Nothing, 100401, IdentityUser.UserCode, My.Request.UserHostAddress.ToString, CrearXMLTransaccion("Consulta Pagina Movil", "/Pagina|" + My.Request.Url.Segments(My.Request.Url.Segments.Length - 1).ToString))
            End Using
        End If
    End Sub

    Private Sub CargarCurriculas()
        Dim ldr As New List(Of IDataReader)
        Using ObjPool As New PoolDbCommand()
            Dim ObjUsuario As New DAL_Kiosco(ObjPool.Database)
            ObjPool.AddDbCommand(ObjUsuario.Get_Curriculas_By_cPerCodigo(lblcPercodigo.Text), PoolDbCommand.PoolDbCommandResultType.Query)
            ObjPool.Pooling(Nothing, ldr, True)
            ObjUsuario = Nothing
            ddcurricula.DataSource = ldr(0)
            ddcurricula.DataTextField = "Descripcion"
            ddcurricula.DataValueField = "ncurcodigo"
            ddcurricula.DataBind()
        End Using
        Call CargarPlanEstudios(ddcurricula.SelectedValue)
    End Sub

    Private Sub CargarPlanEstudios(ByVal nCurCodigo As Integer)
        Dim ldr As New List(Of IDataReader)
        Dim DivPrincipal As New StringBuilder

        DivPrincipal.Append("<table style='width:100%;'>")

        DivPrincipal.Append("<tr style='color:#FFFFFF'>")
        DivPrincipal.Append("   <td style='background-color:#666666;font-size:12px;'>Código</td>")
        DivPrincipal.Append("   <td style='background-color:#666666;font-size:12px;width:35%;'>Asignatura</td>")
        DivPrincipal.Append("   <td style='background-color:#666666;font-size:12px;'>Créditos</td>")
        DivPrincipal.Append("   <td style='background-color:#666666;font-size:12px;width:20%;'>Pre-Requisito</td>")
        DivPrincipal.Append("</tr>")

        Using ObjPool As New PoolDbCommand()
            Dim ObjUsuario As New DAL_Kiosco(ObjPool.Database)
            ObjPool.AddDbCommand(ObjUsuario.Get_PlanEstudios_By_nCurCodigo("1", nCurCodigo), PoolDbCommand.PoolDbCommandResultType.Query)
            ObjPool.Pooling(Nothing, ldr, True)
            ObjUsuario = Nothing
            While ldr(0).Read
                DivPrincipal.Append("<tr>")
                DivPrincipal.Append("   <td style='font-size:10px;'>" + ldr(0).Item("cCurDetCod").ToString + "</td>")
                DivPrincipal.Append("   <td style='font-size:10px;width:35%;'>" + ldr(0).Item("cAsiDescripcion").ToString + "</td>")
                DivPrincipal.Append("   <td style='font-size:10px;'>" + ldr(0).Item("CRED").ToString + "</td>")
                DivPrincipal.Append("   <td style='font-size:10px;width:20%'>" + ldr(0).Item("PREREQ").ToString + "</td>")
                DivPrincipal.Append("</tr>")
            End While
        End Using

        DivPrincipal.Append("</table>")
        lblPlanEstudios.Text = DivPrincipal.ToString
    End Sub

    Protected Sub ddcurricula_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddcurricula.SelectedIndexChanged
        Call CargarPlanEstudios(ddcurricula.SelectedValue)
    End Sub
End Class
